package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.AppMainOperated;
import com.addplus.townmall.server.api.model.town.expand.AppMainOperatedExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * App首页小镇自营 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-11-09
 */
public interface AppMainOperatedMapper extends BaseAddMapper<AppMainOperated> {

    @Select("select sku.sku_describe,a.* from app_main_operated  a LEFT JOIN shop_specification_sku sku ON a.shop_sku_id = sku.id where a.is_deleted=0 order by a.gmt_modified desc")
    List<AppMainOperatedExpand> getAllAppMainOperatedOrderByGmtModifiedDesc(IPage page);
    @Select("select sku.sku_describe,a.* from app_main_operated  a LEFT JOIN shop_specification_sku sku ON a.shop_sku_id = sku.id where a.is_deleted=0 order by a.gmt_modified asc")
    List<AppMainOperatedExpand> getAllAppMainOperatedOrderByGmtModifiedAsc(IPage page);

    @Select("select sku.sku_describe,a.* from app_main_operated  a LEFT JOIN shop_specification_sku sku ON a.shop_sku_id = sku.id where a.is_deleted=0 order by a.sort desc")
    List<AppMainOperatedExpand> getAllAppMainOperatedOrderBySortDesc(IPage page);
    @Select("select sku.sku_describe,a.* from app_main_operated  a LEFT JOIN shop_specification_sku sku ON a.shop_sku_id = sku.id where a.is_deleted=0 order by a.sort asc")
    List<AppMainOperatedExpand> getAllAppMainOperatedOrderBySortAsc(IPage page);

    @Select("select IFNULL(max(sort)+1,1) as sort from app_main_operated where is_deleted=0")
    Integer getMaxSort();
}
